<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <title>修改用户信息</title>
    <script type="application/javascript" th:src="@{/layui/layui.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>

</head>
<body>
  <form class="layui-form" action="/user/updateUser" method="post">
    <div class="layui-form-item">
      <input type="hidden" name="id" th:value="${user.getId()}">
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">用户编号</label>
      <div class="layui-input-block">
        <input type="text" name="userCode" required  lay-verify="required" placeholder="建议使用姓名拼音" autocomplete="off" class="layui-input" th:value="${user.getUserCode()}">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">用户名</label>
      <div class="layui-input-block">
        <input type="text" name="userName" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input" th:value="${user.getUserName()}">
     </div>
     </div>
    <div class="layui-form-item">
      <label class="layui-form-label">出生日期</label>
      <div class="layui-inline">
        <input type="text" class="layui-input" id="test1" name="birthday" th:value="${#dates.format(user.getBirthday(),'yyyy-MM-dd')}">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">性别</label>
      <div class="layui-input-block" >
        <input type="radio" name="gender" value="2" title="男" th:checked="${user.getGender()==2?true:false}">
        <input type="radio" name="gender" value="1" title="女" th:checked="${user.getGender()==1?true:false}">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">电话</label>
      <div class="layui-input-block">
        <input type="tel" name="phone" required  lay-verify="required|phone" placeholder="请输入电话号码" autocomplete="off" class="layui-input" th:value="${user.getPhone()}">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">地址</label>
      <div class="layui-input-block">
        <input type="text" name="address" required  lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input" th:value="${user.getAddress()}">
      </div>
    </div>
    <div class="layui-form-item" sec:authorize="hasRole('ROLE_ADMIN')">
      <label class="layui-form-label">用户角色</label>
      <div class="layui-input-block">
        <select name="userRole" lay-verify="required">
          <option value="2" th:selected="${user.getUserRole()==2?true:false}">经理</option>
          <option value="3" th:selected="${user.getUserRole()==3?true:false}">普通员工</option>
        </select>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
  <script>
    layui.use(['form', 'layer', 'laydate'], function() {
      var laydate = layui.laydate;
      var form = layui.form;
      var layer = layui.layer;

      laydate.render({
        elem: '#test1' //指定元素
      });
    });

  </script>
</body>
</html>